package com.apes.scm.masterdata.frame.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.area.model.Area;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * Created by lishikun on 2020/12/11 10:47
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = StoreAreaInquiry.CONST_TABLE_NAME)
public class StoreAreaInquiry extends Model {

    public static final String CONST_TABLE_NAME = "mas_store_area_inquiry";

    @Id
    @Column(name = "id", length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "门店区域询价", prefix = "1")
    @Comment("编码")
    private String id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "store_id", referencedColumnName = "id", nullable = false)
    @Comment("门店")
    private Store store;

    @Column(name = "STORE_ORIGIN", length = 20)
    @Comment("门店外部ID")
     private String storeOrigin;


    @Name
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "province_id", referencedColumnName = "id")
    @Comment("询价省份")
    private Area province; //省份


    @Name
    @ManyToOne
    @JoinColumn(name = "city_id", referencedColumnName = "id")
    @Comment("询价城市")  //城市
    private Area city;


    @Column(name = "valid", nullable = false, columnDefinition = "number(1,0) default 1")
    @Comment("是否有效")
    private boolean valid = true; //有效

}
